// Achievement by G3X / GeXeH - Enjoy
// Version 1.0

// Achievement: Get into the top 5 survival list.

local total = achievements.GetValue( "Zombie Survival: Survivor", "total", 0 )
if ( achievements.IsGamemode( "Zombie Survival" ) || total == 5 ) then

	local function RcTopTimes( msg )
		local indexx = msg:ReadShort()
		local survivor = msg:ReadString()
		
		for i = string.len( survivor ), 1, -1 do
			if ( string.sub( survivor, i, i ) == " " ) then
				local survivorName = string.Left( survivor, i - 2 )
					if ( LocalPlayer():Name() == survivorName && total != 5 ) then
						total = math.Clamp( total + 1, 0, 5 )
						achievements.Update( "Zombie Survival: Survivor", total / 5, total .. "/5" )
						achievements.SetValue( "Zombie Survival: Survivor", "total", total )
					end
			break
		end
		
end

		return indexx, survivor
	end
	
	usermessage.AddHook( "RcTopTimes", "Achievements.Zombie Survival:Survivor", RcTopTimes )
	
	achievements.Register( "Zombie Survival: Survivor", "Get into the top 5 survival list 5 times.", "achievements/zs_survivor", total / 5, total .. "/5" )
	
end